<?php

namespace App\Modules\Admin\V1\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Laravel\Lumen\Routing\Controller as BaseController;

class DemoController extends BaseController
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    //
    public function Db(Request $request)
    {
        $row = DB::table('yuntu_task_ydz')->where('id', '=', 2)
            ->get();

        echo "<pre>";
        print_r($row);
        exit;

    }

    public function Redis(Request $request)
    {
        $key   = $request->get('key', 'name');
        $value = $request->get('value', '');

        $redisCli = Redis::connection();
        $redisCli->set($key, $value,);
        echo $redisCli->get($key);
    }


    public function bench(Request $request)
    {
        $name = $request->get('name', 'unknown');

        return response()->json([
            'code' => 0,
            'msg'  => '成功',
            'data' => [
                'name' => $name,
            ],
        ]);
    }
}
